package com.masterclient.app.modules.category.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.masterclient.app.R;
import com.masterclient.app.modules.category.beans.CategoryDetailBean;

import java.util.List;

/**
 * 作者：sean
 * 创建时间：2017/6/27 07:15
 * 功能说明：搜索结果侧滑筛选条件中的其它筛选条件
 */

public class AttributesGridAdapter extends BaseAdapter{

    public void setList(List<CategoryDetailBean.ShItemsBean.ShCategorysBean> list ) {
        this.list = list;
        size = list.size();
        notifyDataSetChanged();
    }

    public void setSize(boolean isAll) {
        this.size = isAll?list.size():3;
        notifyDataSetChanged();
    }

    private List<CategoryDetailBean.ShItemsBean.ShCategorysBean> list;
    private Context context;
    private int size=0;
    public AttributesGridAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return list == null?0:size;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        boolean ischeck ;
        TextView tv = (TextView) View.inflate(context, R.layout.text_condition,null);
        CategoryDetailBean.ShItemsBean.ShCategorysBean optionBean = list.get(position);
        tv.setText(optionBean.getSh_name());
        if(optionBean.isCheck()){
            tv.setBackgroundResource(R.drawable.shape_round_f23051_fff2f5);
            tv.setTextColor(0xFFF23051);
        }else {
            tv.setBackgroundResource(R.drawable.shape_round_999faa);
            tv.setTextColor(0xff141922);
        }
        return tv;
    }
}
